package com;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Service
public class TestService {
	
	@Autowired
	private RestTemplate restTemplate;
	
	
	// 设置断路器
	@HystrixCommand(fallbackMethod="error")
	public String test() { // 通过服务名称调用
		return restTemplate.getForObject("http://service/test", String.class);
	}
	
	// 断路器方法
	public String error() {
		return "error";
	}
	
}
